package com.evol.domain.frp;

import com.evol.domain.AjaxResult;
import lombok.Data;

/**
 * 需要指定字段顺序
 * @author EvOL
 * @description
 * @date 2024-05-31 14:36
 **/
@Data
public class Response {
    /**
     * 允许操作
     */
    public boolean unchange;
    /**
     * 拒绝操作
     */
    public boolean reject;
    /**
     * 拒绝操作原因
     */
    public String rejectReason;

    public Object content;

    public Response() {
    }

    public Response(boolean unchange, boolean reject, String rejectReason, Object content) {
        this.unchange = unchange;
        this.reject = reject;
        this.rejectReason = rejectReason;
        this.content = content;
    }
    public static Response success()
    {
        return Response.success(null);
    }
    public static Response success(Object content)
    {
        return new Response(true,false,"",content);
    }
    public static Response error()
    {
        return Response.error("");
    }
    public static Response error(String rejectReason)
    {
        return new Response(false,true,rejectReason,null);
    }
    public String getString(){
        return "{\"reject\":"+this.reject+",\"reject_reason\":\""+this.rejectReason+"\",\"unchange\":"+this.unchange+",\"content\":"+this.content+"}";
    }
}
